package com.basic.business.unsalablePoint.controller;


import java.util.List;
import java.io.IOException;

import com.basic.business.unsalablePoint.domain.TUnsalableActionPoint;
import com.basic.business.unsalablePoint.service.ITUnsalableActionPointService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.common.core.page.TableDataInfo;

/**
 * 滞销行动点Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/unsalablePoint")
public class TUnsalableActionPointController extends BaseController
{
    @Resource
    private ITUnsalableActionPointService tUnsalableActionPointService;

    /**
     * 查询滞销行动点列表
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(TUnsalableActionPoint tUnsalableActionPoint)
    {
        startPage();
        List<TUnsalableActionPoint> list = tUnsalableActionPointService.getList(tUnsalableActionPoint);
        return getDataTable(list);
    }

    /**
     * 导出滞销行动点列表
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:export')")
    @Log(title = "滞销行动点", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "滞销行动点.xlsx")
    @PostMapping("/export")
    public String export(TUnsalableActionPoint tUnsalableActionPoint) throws IOException
    {
        List<TUnsalableActionPoint> list = tUnsalableActionPointService.getList(tUnsalableActionPoint);
        return EasyExcelUtils.excelExport(TUnsalableActionPoint.class,"滞销行动点数据", list);
    }

    /**
     * 获取滞销行动点详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tUnsalableActionPointService.get(id));
    }

    /**
     * 新增滞销行动点
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:add')")
    @Log(title = "滞销行动点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TUnsalableActionPoint tUnsalableActionPoint)
    {
        return toAjax(tUnsalableActionPointService.insert(tUnsalableActionPoint));
    }

    /**
     * 修改滞销行动点
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:edit')")
    @Log(title = "滞销行动点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TUnsalableActionPoint tUnsalableActionPoint)
    {
        return toAjax(tUnsalableActionPointService.update(tUnsalableActionPoint));
    }

    /**
     * 删除滞销行动点
     */
    @PreAuthorize("@ss.hasPermi('business:unsalablePoint:remove')")
    @Log(title = "滞销行动点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tUnsalableActionPointService.deleteByIds(ids));
    }
}
